export default class Singleton {

    public static getIns<T extends {}>(this: new () => T): T {
        if (!(<any>this).instance) {
            (<any>this).instance = new this();
            (<any>this).instance.init();
        }
        return (<any>this).instance;
    }

    public static destroyIns() {
        if ((<any>this).instance) {
            (<any>this).instance!.destroy();
        }
        (<any>this).instance = null;
    }

    destroy(){}
    init(){}
}

